<template>
        <div class="mui-numbox"  data-numbox-min='1' data-numbox-max='9'>
            <button class="mui-btn mui-btn-numbox-minus" type="button">-</button>
            <input id="test" class="mui-input-numbox" type="number" value="1" 
            @change="countChange" ref="numbox"/>
            <button class="mui-btn mui-btn-numbox-plus" type="button">+</button>
		</div>
</template>

<script>
import mui from '../../lib/mui/js/mui.min.js'
export default {
    props:['max'],
    //动态监听库存值，然后设置加减盒子的最大值
    watch:{
        'max':function(newVal,oldVal){
           mui(".mui-numbox").numbox().setOption('max',newVal) 
        }
    },
    data() {
        return {

        };
    },
    mounted(){
        mui(".mui-numbox").numbox();
    },
    methods: {
        //文本框数据改变时传值给父组件
        //当文本只是数字的时候，注意parseInt
        countChange(){
            this.$emit('func',parseInt(this.$refs.numbox.value))
        }
        
    },
};
</script>

<style scoped lang="scss">

</style>
